package com.chf.springboot_test_thymeleaf.dao;

import com.chf.springboot_test_thymeleaf.beans.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {
    /**
     * 查询所有信息
     * @return
     */
    @Select("select * from student")
    public List<Student> QueryAllUserInfo();

    /**
     * 根据ID查询信息
     * @param id
     * @return
     */
    @Select("select * from student where id = #{id}")
    public Student QueryUserInfoById(Integer id);

    /**
     * 修改信息
     * @param student
     * @return
     */
    @Update("update student set name=#{name},age=#{age},sex=#{sex},password=#{password} where id=#{id}")
    public int UpdateUserInfo(Student student);

    /**
     * 删除信息
     * @param id
     * @return
     */
    @Delete("delete from student where id=#{id}")
    public int DeleteUserInfo(Integer id);

    /**
     * 插入信息
     * @param student
     * @return
     */
    @Insert("insert into student(name,age,sex,password) values(#{name},#{age},#{sex},#{password})")
    public int InsertUserInfo(Student student);

    /**
     * 登录验证
     * @param student
     * @return
     */
    @Select("select * from student where name=#{name} and password=#{password}")
    public Student Login(Student student);
}
